package holdtime.xlxc.activities.main;

import android.content.Intent;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import holdtime.xlxc.R;
import holdtime.xlxc.base.BaseActivity;
import holdtime.xlxc.tools.util.SharedPreferencesUtil;
import holdtime.xlxc.tools.util.ToastUtil;

public class Num_Xscx_Activity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        homeAsUpEnabled = true;
        actionBarTitle = "身份证号";
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_num_xscx);

        final EditText addET = (EditText) findViewById(R.id.add_et);
        String add = (String) SharedPreferencesUtil.get(this, "add", "");
        if (!TextUtils.isEmpty(add)) {
            addET.setText(add);
        } else {
            addET.setText("");
        }

        final EditText editText = (EditText) findViewById(R.id.xscx_et);
        String num = (String) SharedPreferencesUtil.get(this, "num", "");
        if (!TextUtils.isEmpty(num)) {
            editText.setText(num);
        }
        Button button = (Button) findViewById(R.id.xscx);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (editText.getText().toString().equals("") || addET.getText().toString().equals("")) {
                    ToastUtil.showToast(Num_Xscx_Activity.this, "请补全信息");
                } else {
                    SharedPreferencesUtil.put(Num_Xscx_Activity.this, "num", editText.getText().toString());
                    SharedPreferencesUtil.put(Num_Xscx_Activity.this, "add", addET.getText().toString());
                    SystemClock.sleep(1000);
                    startActivity(new Intent(Num_Xscx_Activity.this, XscxActivity.class));
                    finish();
                }
            }
        });
    }
}
